<?php
require_once 'Questions.php';
require_once 'Answers.php';
require_once 'Surveys.php';
require_once 'SurveysCompleted.php';

class Survey_QuestionController extends HTech_Controller_Action
{
    function init()
    {
        $cfg = array(
            'model' => 'Questions', 
            'form' => 'Emms_Form_Survey_Question',
            'layout' => array('view' => 'survey'),
            'config' => array('add' => 'survey_questions'),
            'flashMessenger' => true,
            'actionContext' => array(
                'view' => array('prn'))
        );
        parent::init($cfg);
    }
    
    public function addAction()
    {
    }

    public function deactivateAction()
    {
    }
    
    public function viewAction()
    {
        $this->_helper->layout->setLayout('survey'); 
     
        $surveys = new Surveys();
        $questions = new Questions();
        $this->view->SurveyId = $this->_request->getParam('SurveyId');
        $this->view->QuestionId = $this->_request->getParam('QuestionId');
        $data = $questions->find($this->view->QuestionId)->current();
        $this->view->survey = $surveys->find($this->view->SurveyId)->current();
        $this->view->answer = $data->findDependentRowset('Answers');
        //$this->view->data = $data->toArray();
        $this->view->title = $data['Question'];
        $this->view->subtitle = $this->view->survey->Name;        
        $this->view->chart = array('chartId'=>'hitsChart','chartData'=>'/survey/chart/hits/QuestionId/'.$this->view->QuestionId.'/SurveyId/'.$this->view->SurveyId );
    }
}
